package com.lanqiao.dao.impl;

import com.lanqiao.dao.UserDao;
import com.lanqiao.entity.UserInfo;
import com.lanqiao.util.ORMUtil;

import java.util.ArrayList;
import java.util.List;

public class UserDaoImpl implements UserDao {

    @Override
    public List<UserInfo> selectuser(String stu_name, String date, int stu_sex) {
        String sql = "SELECT * from  tb_user where 1=1  ";
        List<Object> params = new ArrayList<>();



        if(stu_name != null && !"".equals(stu_name)){

            sql += "and user_name like ?  ";
            params.add("%"+stu_name+"%");
        }
        if(date != null && !"".equals(date)){

            sql += "and time like ?  ";
            params.add("%"+date+"%");
        }
        if(stu_sex != -1 ){

            sql += "and is_activated = ? ";
            params.add(stu_sex);
        }

        //
        Object[] objects = params.toArray();


//        for(Object ojb : objects){
//            System.out.println(ojb);
//        }

        return  new ORMUtil().selectList(UserInfo.class ,sql,objects);

    }
}
